<?php

class Add extends TPage
{
	private $payment_manager;
	
	public function onLoad($param)
	{
		parent::onLoad($param);
		$this->payment_manager = $this->Application->Modules['payments'];
	}
	
	public function saveButtonClicked($sender, $params)
	{
		if($this->Page->IsValid)
		{
			$result = $this->payment_manager->addPayment(
												$this->value->Text,
												String::format($this->description->Text));

			if($result)
			{
				$this->info->Text = '<p>'.Prado::localize('Changes saved').'</p>';
				$this->clearForm();
			}
			else
				$this->info->Text = '<p>'.Prado::localize('Changes not saved').'</p>';
		}
	}
	
	public function clearForm()
	{
		$this->value->Text = '';
		$this->description->Text = '';
	}
	
	public function getCurrencyName()
	{
		$setting_manager = $this->Application->Modules['settings'];
		if($setting = $setting_manager->getSettingByName(SettingManager::$CURRENCY_NAME))
			return $setting->getValue() != '' ? $setting->getValue() : '-';
		return '-';
	}
}

?>